Skip to content

Deleting a user modal won't close and page won't redirect #6560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions kitsune/sumo/static/sumo/js/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,33 @@
});
}

function handleAccountDeletion() {
// Handle the delete account button click
$('#delete-profile-button').on('click', function(e) {
e.preventDefault();

var $form = $(this).closest('form');

// Close modals - keep both systems for compatibility
if (typeof Mzp !== 'undefined' && Mzp.Modal) {
Mzp.Modal.closeModal();
}

if ($.kbox) {
Copy link
Preview

Copilot AI Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider verifying the existence of $.kbox using a typeof check (e.g. typeof $.kbox !== 'undefined') for consistency with the check for Mzp.Modal to avoid potential run-time errors.

Suggested change
if ($.kbox) {
if (typeof $.kbox !== 'undefined') {

Copilot uses AI. Check for mistakes.

$.kbox.close();
}

// Directly submit the form after a small delay
// This ensures the modal closing completes before submission
setTimeout(function() {
Copy link
Preview

Copilot AI Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a hardcoded delay of 50ms might be brittle if modal closing is slower than expected. Consider implementing a callback from the modal closing process or extracting the delay into a clearly named constant for easier adjustments.

Copilot uses AI. Check for mistakes.

$form[0].submit();
}, 50);
});
}

$(function() {
makeEmailsClickable();
confirmUserDeactivation();
handleAccountDeletion();
});
})(jQuery);